package com.example.demo.handle;

import com.example.demo.domain.Result;
import com.example.demo.girlException.GirlException;
import com.example.demo.utils.ResultUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author 王盼
 * @create 2018-11-19 13:57
 */
@ControllerAdvice
public class ExceptionHandle {
  private final static Logger logger = LoggerFactory.getLogger(ExceptionHandle.class);
  @ExceptionHandler(value = Exception.class)
  @ResponseBody
  public Result handle(Exception e) {
    logger.error("【系统异常】{}", e);
    return ResultUtil.error(-1, "未知错误");
  }
}
/* Logger支持设置日志保存到本地 */